package com.rpc.example;

import com.rpc.example.constant.RegisterType;
import com.rpc.example.nacos.NacosRegisterService;
import com.rpc.example.zookeeper.ZookeeperRegisterService;

public class RegistoryFacory {

    public static IRegitserService createRegisterService(String address, RegisterType register) {
        IRegitserService registerService = null;
        switch (register) {
            case zookeeper:
                try {
                    registerService = new ZookeeperRegisterService(address);
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
                break;
            case nacos:

                try {
                    registerService = new NacosRegisterService(address);
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            default:
        }
        return registerService;
    }
}
